package validate

import (
	"regexp"

	"github.com/go-playground/validator/v10"
)

var username validator.Func = func(fl validator.FieldLevel) bool {
	username := fl.Field().String()
	// 正则表达式：以字母开头，后面可以跟字母、数字或下划线,6-20位
	re := regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9_]{5,19}$`)
	return re.MatchString(username)
}
